//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    internal class PivotSource : IOfficeXmlSerializable
    {
        private string _name;
        private int _fmtId;
        private List< ExtensionList> _extLst = new List<ExtensionList>();

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("pivotSource"))
            {
                _name = c.ReadElementString("name");
                _fmtId = c.ReadElementIntegerAttribute("fmtId");
                _extLst.Clear();
                _extLst.AddRange(c.ReadOptionalWhile<ExtensionList>("extLst")); //\\More than one
            }

        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("pivotSource"))
            {
                c.WriteElementString("name", _name);
                c.WriteElementIntegerAttribute("fmtId", _fmtId);
                c.WriteElements(_extLst);
            }
        }
    }
}